$().ready(function() {
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		save();
	}
});
function save() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/biz/infocoll/csave",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			this.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				layer.msg("操作成功");
				$("#save").text("已提交");
				$("#save").attr("disabled", "disabled");
			} else {
				layer.alert(data.msg)
			}

		}
	});

}
function oneMore() {
	$("#softwareName").val("") ;
	$("#version").val("") ;
	$("#softCompltdate").val("") ;
	$("#publishDate").val("") ;
	$("#programLanguage").val("") ;
	$("#codeLines").val("") ;
	$("#faceIndustry").val("") ;
	$("#mainFunction").val("") ;
	$("#techSpecy").val("") ;
	$("#manualPages").val("") ;
	$("#devCause").val("") ;
	$("#save").text("提交");
	$("#save").removeAttr("disabled");

}

function displayAcception() {
	$('input[type=radio][name=rightGet]').change(function () {
		// 获取input radio选中值，方法一
		var myvalue = $('input:radio[name="rightGet"]:checked').val();
		if(myvalue=="继受取得"){
			$("#acceptType").attr("style","display:block;");
			$("#isRegistered").attr("style","display:block;");
			$("#isModified").attr("style","display:block;");

		}else{
			$("#acceptType").attr("style","display:none;");
			$("#isRegistered").attr("style","display:none;");
			$("#isModified").attr("style","display:none;");

		}

	});


}
function displayPartRight(){
	$('input[type=radio][name=copyrightScope]').change(function () {
		// 获取input radio选中值，方法一
		var myvalue = $('input:radio[name="copyrightScope"]:checked').val();
		if(myvalue=="部分权利"){
			$("#partRight").attr("style","display:block;");


		}else{
			$("#partRight").attr("style","display:none;");


		}

	});
}
function displayModifyContent() {
	$('input[type=radio][name=softwareDescription]').change(function () {
		// 获取input radio选中值，方法一
		var myvalue = $('input:radio[name="softwareDescription"]:checked').val();
		if(myvalue=="修改"){
			$("#modifyContent").attr("style","display:block;");
			$("#modifyContent1").attr("style","display:block;");


		}else{
			$("#modifyContent").attr("style","display:none;");
			$("#modifyContent1").attr("style","display:none;");


		}

	});
}

function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			softwareName : {required : true},
			version : {required : true},
			softwareName : {required : true},
			softCompltdate : {required : true},
			publishDate : {required : true},
			publishCity : {required : true},
			ownerCity : {required : true},
			copyrightOwner : {required : true},
			certNo : {required : true},
			devHardware : {required : true, maxlength : 50},
			runHardware : {required : true, maxlength : 50},
			devOs : {required : true},
			devEnv : {required : true},
			runOs : {required : true},
			runEnv : {required : true},
			programLanguage : {required : true},
			codeLines : {required : true,digits:true},
			faceIndustry : {required : true},
			mainFunction : {required : true, maxlength : 200},
			techSpecy : {required : true, maxlength : 200},
			applier : {required : true,digits:true},
			manualPages : {required : true,digits:true},
			companyOpdate : {required : true},
			address : {required : true,digits:true},
			contact : {required : true,digits:true},
			phone : {required : true,digits:true},
			mobile : {required : true,digits:true},
			devCause : {required : true, maxlength : 50}
		},
		messages : {
			softwareName             : {required : icon + "请输入软件全称"},
			version : {required : icon + "请输入著作权人"},
			softwareName   : {required : icon + "请输入软件名称"},
			softCompltdate    : {required : icon + "请输入软件开发完成日期"},
			publishDate   : {required : icon + "请输入首次发表日期"},
			publishCity: {required : icon + "请选择首次发表城市"},
			ownerCity   : {required : icon + "请选择权利人所在省份和城市"},
			copyrightOwner   : {required : icon + "请输入权利人名称"},
			certNo   : {required : icon + "请输入证件号码"},
			devHardware   : {required : icon + "请输入开发硬件环境",maxlength:icon + "主要功能不能超过50字。"},
			runHardware   : {required : icon + "请输入运行硬件环境",maxlength:icon + "主要功能不能超过50字。"},
			devOs   : {required : icon + "请输入开发该软件的操作系统"},
			devEnv   : {required : icon + "请输入软件开发环境/开发工具"},
			runOs   : {required : icon + "请输入该软件的运行平台/操作系统"},
			runEnv   : {required : icon + "请输入软件运行支撑环境/支持软件"},
			programLanguage   : {required : icon + "请输入编程语言及版本号"},
			codeLines   : {required : icon + "请输入软件代码行数，数值为正整数",digits: icon + "说明书页码必须为正整数"},
			faceIndustry   : {required : icon + "请输入面向领域/行业"},
			mainFunction   : {required : icon + "请输入软件的主要功能",maxlength:icon + "主要功能不能超过200字。"},
			techSpecy   : {required : icon + "请输入软件的技术特点",maxlength:icon + "技术特点不能超过200字。"},
			manualPages   : {required : icon + "请输入说明书页码",digits: icon + "说明书页码必须为正整数"},
			applier   : {required : icon + "请输入申请人"},
			companyOpdate   : {required : icon + "请输入公司成立日期"},
			address   : {required : icon + "请输入详细地址"},
			contact   : {required : icon + "请输入联系人"},
			phone   : {required : icon + "请输入电话"},
			mobile   : {required : icon + "请输入手机"},
			devCause   : {required : icon + "请输入开发目的",maxlength:icon + "主要功能不能超过50字。"}
		}
	})
}